package com.qujia.station.controller;

import com.qujia.common.core.controller.BaseController;
import com.qujia.common.core.domain.AjaxResult;
import com.qujia.common.core.page.TableDataInfo;
import com.qujia.common.exception.CustomException;
import com.qujia.customer.domain.CustomerCardUseRecord;
import com.qujia.customer.service.ICustomerCardUseRecordService;
import com.qujia.station.domain.Enterprise;
import com.qujia.station.domain.Station;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

@Api("充值记录查新")
@RestController
@RequestMapping("/rechargeRecord")
public class RechargeRecordSyncController extends BaseController {
    @Resource
    private ICustomerCardUseRecordService customerCardUseRecordService;

    @GetMapping(value = "/getRechargeRecords")
    public TableDataInfo getRechargeRecords(Station station) {
        if(Objects.isNull(station.getStationId()) && Objects.isNull(station.getEnterpriseId())){
            throw new CustomException("请选传油站ID或者油企ID");
        }
        CustomerCardUseRecord customerCardUseRecord = new CustomerCardUseRecord();
        customerCardUseRecord.setStationId(station.getStationId().intValue());
        customerCardUseRecord.setEnterpriseId(station.getEnterpriseId());
        customerCardUseRecord.setUsageType("+");
        startPage();
        List<CustomerCardUseRecord> customerCardUseRecords = customerCardUseRecordService.selectCustomerCardUseRecordList(customerCardUseRecord);
        return getDataTable(customerCardUseRecords);
    }

}
